//
//  CYMainViewController.swift
//  CYSinaWB
//
//  Created by mac on 16/1/30.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class CYMainViewController: UITabBarController {

    @objc private func plusBtnDidClick() {
        print(__FUNCTION__)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        let mainTabBar = CYMainTabBar()
        setValue(mainTabBar, forKey: "tabBar")
        let actionName = "plusBtnDidClick"
        
        mainTabBar.plusBtn.addTarget(self, action: Selector(actionName), forControlEvents: .TouchUpInside)
        addChildViewControllers()
    }
    
    
   
    
    private func addChildViewControllers() {
//        tabBar.tintColor = UIColor.orangeColor()
        
        addChildViewController(CYHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(CYMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        
        addChildViewController(CYDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(CYProfileTableViewController(), title: "我", imageName: "tabbar_profile")
    }
    private func addChildViewController(vc: UIViewController, title: String,imageName: String) {
    tabBar.tintColor = UIColor.orangeColor()
    
    let nav = BaseNavViewController(rootViewController: vc)
    vc.title = title
    //        homeVC.tabBarItem.title = "首页"
    //        homeVC.navigationItem.title = "首页么"
    
    vc.tabBarItem.image = UIImage(named: imageName)
    //        homeVC.tabBarItem.selectedImage = UIImage(named: "tabbar_home_highlighted")?.imageWithRenderingMode()
    addChildViewController(nav)
    }
    
    
    

}
